#pragma once

#include "comm/znx_log.h"
#include "comm/znx_defs.h"
#include "comm/znx_pool.h"
#include "comm/znx_array.h"
#include "comm/znx_module.h"
#include "comm/znx_string.h"


typedef struct {
    int64_t                 worker_threads;
    int64_t                 tcp_accepter_threads;
    int64_t                 multiple_accept_num;
    int64_t                 thread_session_pool_size;
    int64_t                 g_mem_freelists_level;
    int64_t                 g_aligned_mem_freelists_level;
    int64_t                 worker_mem_freelist_level;
    int64_t                 worker_aligned_mem_freelists_level;
    int64_t                 ssl_session_cache_size;
    znx_str_t               listener_conf_path;
    znx_str_t               http_conf_dir;
    // http_conf_dir + main.yaml
    znx_str_t               http_main_conf_path;
    // http_conf_dir + sites_enabled/main.yaml
    znx_str_t               http_sites_enabled_dir;

    void                    **modules;

    znx_pool_t              *pool;
    znx_str_t               err;
} znx_core_conf_t;


extern znx_core_conf_t      *g_core_conf;

void znx_core_conf_destroy();

znx_bool_t
znx_core_conf_parse(const char *filepath);

#define znx_core_get_module_conf(module)                        \
    g_core_conf->modules[module.index]

#define znx_core_set_module_conf(module, module_conf)           \
    g_core_conf->modules[module.index] = module_conf


// for test
void znx_core_conf_create_default();